/* tslint:disable:member-ordering no-unused-variable */
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { SharedModule } from '../shared/shared.module';

import { HttpService } from './services/http.service';
import { UtilService } from './services/util.service';
import { AuthService } from './services/auth.service';
import { AuthGuard } from './services/auth.guards';

import { RouterReuseStrategyProvider } from './implements/routerReuseStrategy.configurable';
import { HttpSetParamProvider } from './implements/interceptor.setParam';
import { HttpAuthProvider } from './implements/interceptor.auth';

@NgModule({
    imports: [
        HttpClientModule,
        SharedModule
    ],
    providers: [
        HttpService, UtilService,
        AuthService, AuthGuard,
        RouterReuseStrategyProvider,
        HttpSetParamProvider, HttpAuthProvider
    ]
})
export class CoreModule {

    constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
        if (parentModule) {
            throw new Error(
                'CoreModule is already loaded. Import it in the AppModule only');
        }
    }

    static forRoot(config?: any): ModuleWithProviders {
        return {
            ngModule: CoreModule,
            providers: [
                // { provide: UserServiceConfig, useValue: config }
            ]
        };
    }
}
